function str = num2compstr(num, decimal)
    exps = ['M', 'k', ' ', 'm', 'u', 'n', 'p'];
    for k = 1:length(exps)
        numRet = num/10^(9-3*k);
        if (floor(numRet) >= 1) && (floor(numRet) < 1000)
            str = strcat(num2str(round(numRet*(10^decimal))/(10^decimal)), exps(k));
            return
        end
    end
    str = '0';
end